package interfacemanagement;

import java.io.IOException;
import java.sql.SQLException;
import config.ConfigManager;
import dao.DocumentDAO;

public class SetUpInitialValues {
	private DocumentDAO documentDAO;
	private Integer numberOfDocuments;

	public SetUpInitialValues() {
		numberOfDocuments = 0;
	}

	public void setNumberOfDocuments() throws ClassNotFoundException, IOException {
		numberOfDocuments();
		try {
			ConfigManager.writeConfig("numberOfDocuments", numberOfDocuments.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void numberOfDocuments() throws ClassNotFoundException, IOException {
		documentDAO = new DocumentDAO();
		try {
			numberOfDocuments = documentDAO.count();
		} catch (SQLException e) {
			e.printStackTrace();
			numberOfDocuments = 0;
		}
	}

	public Integer getNumberOfDocuments() {
		return numberOfDocuments;
	}
}
